services
  .service("CameraService",function ($q,$cordovaCamera) {
    return {
      getPicture:function (sourceType,destinationType) {
        if(!destinationType){
          destinationType = Camera.DestinationType.DATA_URL;
        }
        if(!sourceType){
          sourceType = Camera.PictureSourceType.CAMERA;
        }
        var deferred= $q.defer();
        // deferred.resolve({status:'1',info:'success'});
        // deferred.reject({status:'0',info:'failed'});
        //拍照
        var options={
          quality:50,                                       //保存图像的质量，范围0-100
          destinationType:destinationType,  //返回值格式:DATA_URL=0,返回作为base64编码字符串；FILE_URL=1，返回图像的URL；NATIVE_RUL=2，返回图像本机URL
          sourceType:sourceType,       //设置图片来源：PHOTOLIBRARY=0，相机拍照=1，
          allowEdit:true,                                   //选择图片前是否允许编辑
          encodingType:Camera.EncodingType.JPEG,            //JPEN = 0，PNG = 1
          targetWidth:100,                                  //缩放图像的宽度（像素）
          targetHeight:100,                                 //缩放图像的高度（像素）
          popoverOptions:CameraPopoverOptions,              //ios,iPad弹出位置
          saveToPhotoAlbum:false,                            //是否保存到相册
          correctOrientation:true                           //设置摄像机拍摄的图像是否为正确的方向
        };
        $cordovaCamera.getPicture(options).then(function(imageData){
          deferred.resolve(imageData);
        },function(err){
          deferred.reject(err);
        });
        return deferred.promise;
      }
    }
  });
